<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
	// 递归：在函数内部自己调用自己

	// 阶乘：5! = 5*4*3*2*1

	// 用来计算阶乘的函数
	function jiecheng(num){
		if(num==1){
			return 1;
		}
		var re = num*jiecheng(num-1);
		return re;
	}

	alert(jiecheng(120));

// 伪代码：
jiecheng(5){
	return 5*jiecheng(4){
		return 4*jiecheng(3){
			return 3*jiecheng(2){
				return 2*jiecheng(1){
					return 1;
				}
			}
		}
	}
}

</script>
</head>

<body>
</body>
</html>
